package com.shell.customer.base.rx;

import com.shell.customer.base.CusEvent;
import com.shell.customer.base.service.CusTagRecService;
import com.shell.customer.base.vo.CusRecVo;
import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class SetBaseTagSubscriber extends OnErrorNotImplementedSubscriber<CusEvent> {
	@Autowired
	private CusTagRecService cusTagRecService;

	public void onApplicationEvent(CusEvent event) {
		CusRecVo cusVo = event.getCusRecVo();
		if ((cusVo.getCusType().equals("FINNER")) || (cusVo.getCusType().equals("ENTERPRISE"))) {
			this.cusTagRecService.saveCusRecTag(cusVo.getCusId(), "", "BASIC_SERVICE");
			if ((cusVo.isOperator()) && (event.isAdd())) {
				this.cusTagRecService.saveCusRecTag(cusVo.getCusId(), "", "OPERATOR");
			}
			if ((cusVo.isArtisan()) && (event.isAdd())) {
				this.cusTagRecService.saveCusRecTag(cusVo.getCusId(), "", "ARTISAN");
			}
			this.cusTagRecService.syncCusBiz(cusVo.getCusId());
		}
	}
}
